workspace(name="py_extension")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") 


# Python rule
# -------------------
http_archive(
    name = "rules_python",
    integrity = "sha256-qDdnnxOC8mlowe5vg5x9r5B5qlMSgGmh8oFd7KpjcwQ=",
    strip_prefix = "rules_python-1.4.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/1.4.0/rules_python-1.4.0.tar.gz",
)

# Python repositories (e.g. bazel_skylib)
# -------------------
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()

load("@rules_python//python:pip.bzl", "pip_parse")


# Python requirements
# -------------------
pip_parse(
   name = "my_deps_1",
   requirements_lock = "@py_extension//:requirements_lock_1.txt",
)

pip_parse(
    name = "my_deps_2",
    requirements_lock = "@py_extension//:requirements_lock_2.txt",
)

pip_parse(
    name = "pypi",
    python_interpreter_target = "@python_3_11_host//:python",
    requirements_lock = "//:requirements_lock_pypi.txt",
)

load("@my_deps_1//:requirements.bzl", install_deps_1 = "install_deps")
install_deps_1()

load("@my_deps_2//:requirements.bzl", install_deps_2 = "install_deps")
install_deps_2()

load("@pypi//:requirements.bzl", install_deps_pypi = "install_deps")
install_deps_pypi()

# Python toolchains
# -------------------
load("@rules_python//python:repositories.bzl", "python_register_toolchains", "python_register_multi_toolchains")

DEFAULT_PYTHON = "3.11"

python_register_multi_toolchains(
    name = "python",
    default_version = DEFAULT_PYTHON,
    python_versions = [
      "3.12",
      "3.10",
    ],
)

python_register_toolchains(
    name = "python_3_11",
    python_version = "3.11",
)
